package com.taikang.common.util;

import java.util.Date;

import org.apache.commons.beanutils.Converter;

public class DateConvert implements Converter {

	@SuppressWarnings("unchecked")
	public Object convert(Class arg0, Object value) {

		if (value == null || "".equals(value)) {
			return value;
		}
		if (value instanceof Date) {
			return (value);
		}
		try {
			return DateUtils.parseTime(value.toString());
		} catch (Exception e) {
			try {
				return DateUtils.parseDate(value.toString());
			} catch (Exception ex) {
				return null;
			}
		}
	}
}
